package com.ruoyi.teaching.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.teaching.api.RemoteTeachingService;
import com.ruoyi.teaching.api.domain.CurriculumDto;
import com.ruoyi.teaching.api.domain.FocusStudentDto;
import com.ruoyi.teaching.api.domain.TeachingTraceDto;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

import static com.ruoyi.common.core.web.domain.AjaxResult.error;

/**
 * @author Mouyiheng
 */
@Component
public class RemoteTeachingFallbackFactory implements FallbackFactory<RemoteTeachingService> {
    @Override
    public RemoteTeachingService create(Throwable cause) {
        return new RemoteTeachingService(){
            @Override
            public R<Void> reminderTracking() {
                return R.fail("远程调用老师中心服务reminderTracking方法失败");
            }

            @Override
            public AjaxResult getList(CurriculumDto curriculumDto) {
                return error("远程调用老师中心服务reminderTracking方法失败");
            }

            @Override
            public AjaxResult addStudentFocus(FocusStudentDto focusStudentDto) {
                return AjaxResult.error("远程调用失败");
            }

            @Override
            public AjaxResult add(List<TeachingTraceDto> teachingTraces) {
                return AjaxResult.error("远程调用失败");
            }
        };
    }
}
